package com.hddznet.uniplatform.sm.service.impl;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hddznet.uniplatform.sm.entity.BusZyPreparStepEntity;
import com.hddznet.uniplatform.sm.mapper.BusZyPreparStepMapper;
import com.hddznet.uniplatform.sm.mapper.SysDictItemMapper;
import com.hddznet.uniplatform.sm.service.IBusZyService;
import com.hddznet.uniplatform.sm.util.HdCustomQueryUtils;

@Service
public class BusZyServiceImpl implements IBusZyService {

	@Autowired
	private SysDictItemMapper sysDictItemMapper;
	
	@Autowired
	private BusZyPreparStepMapper busZyPreparStepMapper;

	@Override
	public boolean savePreparStep(BusZyPreparStepEntity entity) {
		entity.setId(null);
		Date now = new Date();
		entity.setCreateTime(now);
		entity.setUpdateTime(null);
		if (busZyPreparStepMapper.insert(entity) > 0) {
			return true;
		}
		return false;
	}
	
	@Override
	public boolean modifyPreparStep(BusZyPreparStepEntity entity) {
		Date now = new Date();
		entity.setUpdateTime(now);
		if (busZyPreparStepMapper.updateById(entity) > 0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean delPreparStep(String id) {
		busZyPreparStepMapper.deleteById(id);
		return true;
	}
	
	@Override
	public IPage<BusZyPreparStepEntity> queryPreparStep(BusZyPreparStepEntity entity, Map<String, String[]> parameterMap, Integer pageNo,  Integer pageSize) {
		QueryWrapper<BusZyPreparStepEntity> queryWrapper = HdCustomQueryUtils.initQueryWrapper(entity, parameterMap);
		Page<BusZyPreparStepEntity> page = new Page<BusZyPreparStepEntity>(pageNo, pageSize);
		IPage<BusZyPreparStepEntity> pageList = busZyPreparStepMapper.selectPage(page, queryWrapper);
		return pageList;
	}

	
}
